/**
 */
package org.xtext.mydsl.scheduler.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import org.xtext.mydsl.scheduler.Cierre;
import org.xtext.mydsl.scheduler.Dia;
import org.xtext.mydsl.scheduler.Dicta;
import org.xtext.mydsl.scheduler.Inaguracion;
import org.xtext.mydsl.scheduler.SchedulerPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Dia</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.xtext.mydsl.scheduler.impl.DiaImpl#getNumero <em>Numero</em>}</li>
 *   <li>{@link org.xtext.mydsl.scheduler.impl.DiaImpl#getInauguracion <em>Inauguracion</em>}</li>
 *   <li>{@link org.xtext.mydsl.scheduler.impl.DiaImpl#getEventos <em>Eventos</em>}</li>
 *   <li>{@link org.xtext.mydsl.scheduler.impl.DiaImpl#getCierre <em>Cierre</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class DiaImpl extends MinimalEObjectImpl.Container implements Dia
{
  /**
   * The default value of the '{@link #getNumero() <em>Numero</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getNumero()
   * @generated
   * @ordered
   */
  protected static final int NUMERO_EDEFAULT = 0;

  /**
   * The cached value of the '{@link #getNumero() <em>Numero</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getNumero()
   * @generated
   * @ordered
   */
  protected int numero = NUMERO_EDEFAULT;

  /**
   * The cached value of the '{@link #getInauguracion() <em>Inauguracion</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getInauguracion()
   * @generated
   * @ordered
   */
  protected Inaguracion inauguracion;

  /**
   * The cached value of the '{@link #getEventos() <em>Eventos</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getEventos()
   * @generated
   * @ordered
   */
  protected EList<Dicta> eventos;

  /**
   * The cached value of the '{@link #getCierre() <em>Cierre</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getCierre()
   * @generated
   * @ordered
   */
  protected Cierre cierre;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected DiaImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return SchedulerPackage.Literals.DIA;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public int getNumero()
  {
    return numero;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setNumero(int newNumero)
  {
    int oldNumero = numero;
    numero = newNumero;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, SchedulerPackage.DIA__NUMERO, oldNumero, numero));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Inaguracion getInauguracion()
  {
    return inauguracion;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetInauguracion(Inaguracion newInauguracion, NotificationChain msgs)
  {
    Inaguracion oldInauguracion = inauguracion;
    inauguracion = newInauguracion;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SchedulerPackage.DIA__INAUGURACION, oldInauguracion, newInauguracion);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setInauguracion(Inaguracion newInauguracion)
  {
    if (newInauguracion != inauguracion)
    {
      NotificationChain msgs = null;
      if (inauguracion != null)
        msgs = ((InternalEObject)inauguracion).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - SchedulerPackage.DIA__INAUGURACION, null, msgs);
      if (newInauguracion != null)
        msgs = ((InternalEObject)newInauguracion).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - SchedulerPackage.DIA__INAUGURACION, null, msgs);
      msgs = basicSetInauguracion(newInauguracion, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, SchedulerPackage.DIA__INAUGURACION, newInauguracion, newInauguracion));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Dicta> getEventos()
  {
    if (eventos == null)
    {
      eventos = new EObjectContainmentEList<Dicta>(Dicta.class, this, SchedulerPackage.DIA__EVENTOS);
    }
    return eventos;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Cierre getCierre()
  {
    return cierre;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetCierre(Cierre newCierre, NotificationChain msgs)
  {
    Cierre oldCierre = cierre;
    cierre = newCierre;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SchedulerPackage.DIA__CIERRE, oldCierre, newCierre);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setCierre(Cierre newCierre)
  {
    if (newCierre != cierre)
    {
      NotificationChain msgs = null;
      if (cierre != null)
        msgs = ((InternalEObject)cierre).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - SchedulerPackage.DIA__CIERRE, null, msgs);
      if (newCierre != null)
        msgs = ((InternalEObject)newCierre).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - SchedulerPackage.DIA__CIERRE, null, msgs);
      msgs = basicSetCierre(newCierre, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, SchedulerPackage.DIA__CIERRE, newCierre, newCierre));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case SchedulerPackage.DIA__INAUGURACION:
        return basicSetInauguracion(null, msgs);
      case SchedulerPackage.DIA__EVENTOS:
        return ((InternalEList<?>)getEventos()).basicRemove(otherEnd, msgs);
      case SchedulerPackage.DIA__CIERRE:
        return basicSetCierre(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case SchedulerPackage.DIA__NUMERO:
        return getNumero();
      case SchedulerPackage.DIA__INAUGURACION:
        return getInauguracion();
      case SchedulerPackage.DIA__EVENTOS:
        return getEventos();
      case SchedulerPackage.DIA__CIERRE:
        return getCierre();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case SchedulerPackage.DIA__NUMERO:
        setNumero((Integer)newValue);
        return;
      case SchedulerPackage.DIA__INAUGURACION:
        setInauguracion((Inaguracion)newValue);
        return;
      case SchedulerPackage.DIA__EVENTOS:
        getEventos().clear();
        getEventos().addAll((Collection<? extends Dicta>)newValue);
        return;
      case SchedulerPackage.DIA__CIERRE:
        setCierre((Cierre)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case SchedulerPackage.DIA__NUMERO:
        setNumero(NUMERO_EDEFAULT);
        return;
      case SchedulerPackage.DIA__INAUGURACION:
        setInauguracion((Inaguracion)null);
        return;
      case SchedulerPackage.DIA__EVENTOS:
        getEventos().clear();
        return;
      case SchedulerPackage.DIA__CIERRE:
        setCierre((Cierre)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case SchedulerPackage.DIA__NUMERO:
        return numero != NUMERO_EDEFAULT;
      case SchedulerPackage.DIA__INAUGURACION:
        return inauguracion != null;
      case SchedulerPackage.DIA__EVENTOS:
        return eventos != null && !eventos.isEmpty();
      case SchedulerPackage.DIA__CIERRE:
        return cierre != null;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (numero: ");
    result.append(numero);
    result.append(')');
    return result.toString();
  }

} //DiaImpl
